local UIBase = require("view.UIBase")
local LunchUI = class("LunchUI", UIBase)
local UIUtil = require("utils.UIUtil")
local GameUtils = require("utils.GameUtils")
local UIManager = require("manager.UIManager")

function LunchUI:ctor(sceneId)
    self._sceneId = sceneId
    local resource = {
        path = "Prefabs/UI",
        name = "LunchUI",
        canvas = 1
    }
    LunchUI.super.ctor(self, resource)
end

function LunchUI:start()
    UIUtil.addTouchEvent(self._imageHead.transform, nil, nil, handler(self, self._onHeadClick))

    self._btnGm.onClick:AddListener(handler(self, self._onBtnGmClick))
    if DEBUG then
        self._btnGm.gameObject:SetActive(true)
    else
        self._btnGm.gameObject:SetActive(false)
    end
    self._btnMail.onClick:AddListener(handler(self, self._onBtnMailClick))
    self._btnBag.onClick:AddListener(handler(self, self._onBtnBagClick))
    self._btnNear.onClick:AddListener(handler(self, self._onBtnNearClick))
    if G_SocketManager:isContenting() then
        self._btnNear.gameObject:SetActive(true)
    else
        self._btnNear.gameObject:SetActive(false)
    end
end

function LunchUI:onUpdateItem(item, index)
    local text = item:GetComponentInChildren(typeof(Unity.UI.Text))
    text.text = index
end

function LunchUI:close()
    GameUtils.destroy(self.gameObject)
end

function LunchUI:_onBtnGoClick()
end

function LunchUI:_onBtnEquipClick()
end

function LunchUI:_onHeadClick()
    printDebug("LunchUI:_onHeadClick")
    local team = require("view.teamView.TeamView").new()
end

function LunchUI:_onBtnGmClick()
    local gm = require("view.gm.GMView").new()
end

function LunchUI:_onBtnMailClick()
    local mail = require("view.mail.MailView").new()
end

function LunchUI:_onBtnBagClick()
    local package = require("view.package.PackageView").new()
end

function LunchUI:_onBtnShopClick()
end

function LunchUI:_onBtnNearClick()
    local view = require("view.nearView.NearPlayerView").new(self._sceneId)
end

return LunchUI
